package com.huaxia.dao.promotion;

import com.huaxia.pojo.promotion.BranchBC;

import org.apache.ibatis.annotations.Select;


import java.util.List;

/**
 * @author wangli 爱我华夏，爱我中华！
 * @date 2020/06/09 14:31
 */


public interface BranchBcMapper {

    @Select("select b.branchsname,b.branchNumBC,a.branchQuarterNumBC,round(decode(b.branchNumBC,0,0,a.branchQuarterNumBC*100/b.branchNumBC),1)branchYieldBC from\n" +
            "(select sb.branchsname,NVL(a.num,0)branchQuarterNumBC from\n" +
            "(select t.branchcode,count(t.branchcode)num from D_AGENT_PROVINCE_YX2 t where t.agentgrade='BC' and to_char(t.startdate,'q')=to_char(sysdate,'q') and t.agentstate='在职' group by t.branchcode)a right join SD_BRANCH sb on sb.branchcode=a.branchcode\n" +
            ")a,\n" +
            "(select sb.branchsname,NVL(a.num,0)branchNumBC from\n" +
            "(select t.branchcode,count(t.branchcode)num from D_AGENT_PROVINCE_YX2 t where t.agentgrade='BC' and t.agentstate='在职' group by t.branchcode)a right join SD_BRANCH sb on sb.branchcode=a.branchcode\n" +
            ")b where a.branchsname=b.branchsname order by a.branchQuarterNumBC DESC")
    List<BranchBC> getBranchBC();
}
